package com.systemic.service.impl;

import com.systemic.mapper.MindfulnessEvaluateMapper;
import com.systemic.pojo.MindfulnessEvaluate;
import com.systemic.service.MindfulnessEvaluateService;
import com.systemic.vo.PageVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: MindfulnessEvaluateServiceImpl
 * @Description:
 * @Author:
 * @CreateTime: 2024-02-02 09:23
 * @Version:
 **/
@Service
public class MindfulnessEvaluateServiceImpl implements MindfulnessEvaluateService {

    @Resource
    private MindfulnessEvaluateMapper mindfulnessEvaluateMapper;

    @Override
    @Transactional
    public int add(MindfulnessEvaluate mindfulnessEvaluate) {
        int row = 0;
        row = mindfulnessEvaluateMapper.insert(mindfulnessEvaluate)+row;
        return row;
    }

    @Override
    @Transactional
    public int delete(Integer id) {
        int row = 0;
        MindfulnessEvaluate mindfulnessEvaluate = new MindfulnessEvaluate();
        mindfulnessEvaluate.setId(id);
        row = mindfulnessEvaluateMapper.delete(mindfulnessEvaluate)+row;
        return row;
    }

    @Override
    @Transactional
    public int update(MindfulnessEvaluate mindfulnessEvaluate) {
        int row = 0;
        row = mindfulnessEvaluateMapper.update(mindfulnessEvaluate)+row;
        return row;
    }

    @Override
    public List<MindfulnessEvaluate> selectByMid(PageVo pageVo) {
        // 获取当前页数和每页显示的数据条数
        Integer pageNo = pageVo.getPageNo();
        Integer pageSize = pageVo.getPageSize();
        // 计算OFFSET值
        Integer offset = (pageNo - 1) * pageSize;
        Integer mid = pageVo.getMid();
        return mindfulnessEvaluateMapper.selectListByMid(mid,offset,pageSize);
    }
}
